var Sequelize = require('sequelize');
var config = require('../configs');

const Op = Sequelize.Op;
// 创建数据库连接
var sequelize = new Sequelize(config.db.name, config.db.user, config.db.pwd, {
  host: config.db.host,
  dialect: 'mysql',
  directory: false, // prevents the program from writing to disk
  port: config.db.port,
  additional: {
    timestamps: true
  },
  define: {
    timestamps: true
  },
  isolationLevel: Sequelize.Transaction.ISOLATION_LEVELS.SERIALIZABLE,
  logging: false,
  pool: {
    max: 200,
    min: 0,
    acquire: 5000,
    idle: 5000
  },
  timezone: '+08:00'
});

module.exports = require('../models/init-models.js').initModels(sequelize);
module.exports.sequelize = sequelize;
module.exports.Op = Op;
module.exports.Sequelize = Sequelize;
